import 'package:json_annotation/json_annotation.dart';

part 'base_response.g.dart';

///
/// @Author: Lee
/// @Date: 2025/1/22 15:55
/// @Description: 基础的Response响应
///
@JsonSerializable(genericArgumentFactories: true)
class BaseResponse<T, E> {
  final int returnCode;
  final String returnMessage;
  final T? data;
  final List<E>? dataList;

  const BaseResponse(
      this.returnCode, this.returnMessage, this.data, this.dataList);

  factory BaseResponse.fromJson(
    Map<String, dynamic> json,
    T Function(Object? json) fromJsonT,
    E Function(Object? jsonList) fromJsonE,
  ) =>
      _$BaseResponseFromJson(json, fromJsonT, fromJsonE);

  Map<String, dynamic> toJson(Object? Function(T value) toJsonT,
          Object? Function(E value) toJsonE) =>
      _$BaseResponseToJson(this, toJsonT, toJsonE);
}
